package com.ymatou.iapi.leaf.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.leaf.parameter.GetSeqReq;
import com.ymatou.iapi.leaf.service.GetSeqIdsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;

public class Ts_GetSeqIds {

	private static GetSeqReq req;
	private static GetSeqIdsCall call;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("创建序列号");

	}

	@Before
	public void caseUp() {

		req = new GetSeqReq();
		call = new GetSeqIdsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetSeqIds_001() {
		Logger.start(true, "创建序列号");
		try {

			req.setCount(10);
			req.setSeqName("temp_0");

			call.setData(req);
			call.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetSeqIds_002() {
		Logger.start(true, "SeqNamclear不存在");
		try {

			req.setCount(10);
			req.setSeqName("tem_99");

			call.setData(req);
			call.callService();

			Logger.verifyEquals("ILLEGAL_ARGUMENT",
					call.getString("errorCode"), "校验errorCode");
			Logger.verifyEquals(
					String.format("seqName:%s非法,请先申请该序列号.", req.getSeqName()),
					call.getString("errorMessage"), "校验errorMessage");

			Logger.verifyEquals(false, new Boolean(call.getString("success")),
					"校验success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
